pv-on-hvm: fix/adjust pv driver's mkbuildtree
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Jan 2008 15:28:59 +0000 (15:28 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Jan 2008 15:28:59 +0000 (15:28 +0000)
Allow invoking the script from other than the current directory (the
script now infers the tree is where the script lives). Print which
trees are actually being used.

Fix the linking of sources from Linux tree's drivers/xen/ - this was
needlessly invoking lndir on various sub-directories, in some cases
even twice.

Adjust the script to be able to deal with Linux 2.6.24's unified x86
include directory.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
unmodified_drivers/linux-2.6/mkbuildtree

index 741dabc52a99f3d59fa006301fea9121d7ee38b2..88985a5063bb4fbae261a09dcf4c5e0c20bb0512 100755 (executable)
@@ -8,27 +8,28 @@ else
     echo "This may be overridden on the command line (i386,x86_64,ia64)."
 fi
 
-C=$PWD
+C=$(cd $(dirname $0) && pwd)
+R=${C%/*/*}
 
 if [ -n "$XEN" -a -d "$XEN" ]; then
   XEN=$(cd $XEN && pwd)
 else
-  XEN=$C/../../xen
+  XEN=$R/xen
 fi
+echo "Xen tree: $XEN"
 
 if [ -n "$XL" -a -d "$XL" ]; then
   XL=$(cd $XL && pwd)
 else
-  XL=$C/../../linux-2.6.18-xen.hg
+  XL=$R/linux-2.6.18-xen.hg
 fi
+echo "Linux tree: $XL"
 
-for d in $(find ${XL}/drivers/xen/ -maxdepth 1 -type d | sed -e 1d); do
-    if ! echo $d | egrep -q back; then
-        lndir $d $(basename $d) > /dev/null 2>&1
-    fi
-    if ! echo $d | egrep -q ball; then
-        lndir $d $(basename $d) > /dev/null 2>&1
-    fi
+cd $C
+
+for d in $(find ${XL}/drivers/xen/ -mindepth 1 -maxdepth 1 -type d); do
+    test -d $(basename $d) || continue
+    lndir $d $(basename $d) > /dev/null 2>&1
 done
 
 ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
@@ -44,23 +45,27 @@ ln -nsf ${XEN}/include/public include/xen/interface
 # Need to be quite careful here: we don't want the files we link in to
 # risk overriding the native Linux ones (in particular, system.h must
 # be native and not xenolinux).
-case "$uname"
-in
-"x86_64")
-    ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypervisor.h include/asm
-    ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypercall.h include/asm
-    ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/synch_bitops.h include/asm
-    ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/maddr.h include/asm
-    ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/gnttab_dma.h include/asm
-    mkdir -p include/asm-i386
-    lndir -silent ${XL}/include/asm-i386 include/asm-i386
-  ;;
-i[34567]86)
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypervisor.h include/asm
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/gnttab_dma.h include/asm
+case "$uname" in
+i[34567]86|x86_64)
+    if [ -d ${XL}/include/asm-x86 ]; then
+        ln -sf ${XL}/include/asm-x86/mach-xen/asm/hypervisor.h include/asm
+        ln -sf ${XL}/include/asm-x86/mach-xen/asm/hypercall*.h include/asm
+        ln -sf ${XL}/include/asm-x86/mach-xen/asm/synch_bitops*.h include/asm
+        ln -sf ${XL}/include/asm-x86/mach-xen/asm/maddr*.h include/asm
+        ln -sf ${XL}/include/asm-x86/mach-xen/asm/gnttab_dma.h include/asm
+    else
+        if [ $uname = x86_64 ]; then
+            mkdir -p include/asm-i386
+            lndir -silent ${XL}/include/asm-i386 include/asm-i386
+        else
+            uname=i386
+        fi
+        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/hypervisor.h include/asm
+        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/hypercall.h include/asm
+        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/synch_bitops.h include/asm
+        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/maddr.h include/asm
+        ln -sf ${XL}/include/asm-$uname/mach-xen/asm/gnttab_dma.h include/asm
+    fi
   ;;
 "ia64")
     ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm